<?php
	$ano = $_GET['ano'];
	
	include 'open-connection.php';
	
	// Performing SQL query
	$query = "SELECT MONTH(consulta.fecha) AS MES, YEAR(consulta.fecha) AS ANO, COUNT(*) AS CONT
	 FROM consulta WHERE YEAR(consulta.fecha) = $ano OR $ano = 0
	 GROUP BY YEAR(consulta.fecha), MONTH(consulta.fecha)
	 ORDER BY MONTH(consulta.fecha)";
	$result = mysql_query($query) or die('Query failed: ' . mysql_error());
	
	while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
		$arr[] = $line;
	}

	include 'close-connection.php';
	
	echo json_encode($arr);
?>